import Vue from 'vue';
import Router from 'vue-router';
import model from '@/router/module/model';
import personalCenter from '@/router/module/personalCenter';
Vue.use(Router);

const routerPush = Router.prototype.push;
Router.prototype.push = function push(location, onResolve, onReject) {
  if(onResolve || onReject) return routerPush.call(this, location, onResolve, onReject);
  return routerPush.call(this, location).catch((error) => error);
};
const children = [...model, ...personalCenter]
const router = new Router({
	routes: [{
			path: '*',
			name: 'index',
			redirect: "/model-square",
			component: resolve => require(['@/views/Index'], resolve),
			children:[
				{
					path: '/model-square',
					component: () => import('@/views/model/modelSquare'),
					title:"模型广场",
					name:"modelSquare"
				},
			]
		},

		{
			path: '/login',
			name: 'login',
			component: resolve => require(['@/views/Login.vue'], resolve)
		},
		{
			path: '/index',
			name: 'index',
			redirect: "/model-square",
			component: resolve => require(['@/views/Index.vue'], resolve),
			children
		}
	]
});

export default router;